package com.uzai.console.service.turnlink.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.uzai.console.entity.TlLeagueSettingRelDo;
import com.uzai.console.mapper.TlLeagueSettingRelMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author mingyang.chen create in 2022/11/3 17:55
 */
@Service
public class TlLeagueSettingRelService extends ServiceImpl<TlLeagueSettingRelMapper, TlLeagueSettingRelDo> {


    public List<TlLeagueSettingRelDo> listBySettingIds(Long merId, List<Long> settingIds) {

        LambdaQueryWrapper<TlLeagueSettingRelDo> condition = Wrappers.lambdaQuery(TlLeagueSettingRelDo.class);

        condition.eq(TlLeagueSettingRelDo::getMerId, merId)
                .in(TlLeagueSettingRelDo::getTlLeagueSettingId, settingIds);

        return this.list(condition);
    }

    public List<TlLeagueSettingRelDo> listBySettingId(Long merId, Long settingId) {
        LambdaQueryWrapper<TlLeagueSettingRelDo> condition = Wrappers.lambdaQuery(TlLeagueSettingRelDo.class);

        condition.eq(TlLeagueSettingRelDo::getMerId, merId)
                .eq(TlLeagueSettingRelDo::getTlLeagueSettingId, settingId);

        return this.list(condition);
    }

    public Boolean deleteBySettingId(Long merId, Long settingId) {

        LambdaQueryWrapper<TlLeagueSettingRelDo> condition = Wrappers.lambdaQuery(TlLeagueSettingRelDo.class);

        condition.eq(TlLeagueSettingRelDo::getMerId, merId)
                .eq(TlLeagueSettingRelDo::getTlLeagueSettingId, settingId);


        return this.remove(condition);
    }
}
